package com.lly.tboc.zhouyi.api

import okhttp3.HttpUrl
import okhttp3.Interceptor
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.ResponseBody
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

interface UploadFileApi {
    @Multipart
    @POST("/")
    suspend fun upLoadFile(@Part file: MultipartBody.Part): ResponseBody

    companion object {
        fun create(httpUrl: HttpUrl,logger: Interceptor): UploadFileApi {
            val client = OkHttpClient.Builder()
                .addInterceptor(logger)
                .build()
            return Retrofit.Builder()
                .baseUrl(httpUrl)
                .client(client)
                .addConverterFactory(GsonConverterFactory.create())
                .build()
                .create(UploadFileApi::class.java)
        }
    }

}